﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/AdminDefault.Master" AutoEventWireup="true"
  CodeBehind="PhotoAlbums.aspx.cs" Inherits="ITViet.Web.Admin.PhotoAlbums" Title="" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <div style="padding-top: 10px;">
    <dxwgv:ASPxGridView ID="gvList" runat="server" AutoGenerateColumns="False" ClientInstanceName="gvList"
      KeyFieldName="Id" Width="100%" OnCustomJSProperties="gvList_CustomJSProperties"
      OnRowDeleting="gvList_RowDeleting" OnRowInserting="gvList_RowInserting" OnRowUpdating="gvList_RowUpdating"
      OnHtmlDataCellPrepared="gvList_HtmlDataCellPrepared" OnCustomCallback="gvList_CustomCallback"
      OnCommandButtonInitialize="gvList_CommandButtonInitialize" OnDataBound="gvList_DataBound">
      <SettingsBehavior ConfirmDelete="True" AllowDragDrop="false" AllowSort="false" />
      <SettingsPager>
        <AllButton>
          <Image Height="19px" Width="28px" />
        </AllButton>
        <FirstPageButton>
          <Image Height="19px" Width="23px" />
        </FirstPageButton>
        <LastPageButton>
          <Image Height="19px" Width="23px" />
        </LastPageButton>
        <NextPageButton>
          <Image Height="19px" Width="19px" />
        </NextPageButton>
        <PrevPageButton>
          <Image Height="19px" Width="19px" />
        </PrevPageButton>
        <Summary AllPagesText="<%$Resources:Strings, PagerText %>" Text="<%$Resources:Strings, PagerText %>" />
      </SettingsPager>
      <Images>
        <CollapsedButton Height="14px" Width="13px" />
        <ExpandedButton Height="13px" Width="13px" />
        <DetailCollapsedButton Height="13px" Width="13px" />
        <DetailExpandedButton Height="13px" Width="13px" />
        <HeaderFilter Height="19px" Width="19px" />
        <HeaderActiveFilter Height="19px" Width="19px" />
        <HeaderSortDown Height="3px" Width="6px" />
        <HeaderSortUp Height="3px" Width="6px" />
        <FilterRowButton Height="13px" Width="13px" />
        <CustomizationWindowClose Height="18px" Width="18px" />
        <PopupEditFormWindowClose Height="18px" Width="18px" />
        <WindowResizer Height="12px" Width="12px" />
        <FilterBuilderClose Height="18px" Width="18px" />
      </Images>
      <Columns>
        <dxwgv:GridViewCommandColumn Name="Command" ButtonType="Image" VisibleIndex="0" 
          Width="60px" Caption=" ">
          <EditButton Visible="True">
            <Image Url="~/images/edit.png" />
          </EditButton>
          <NewButton Visible="True">
            <Image Url="~/images/add.png" />
          </NewButton>
          <DeleteButton Visible="True">
            <Image Url="~/images/delete.png" />
          </DeleteButton>
          <CancelButton>
            <Image Url="~/images/undo.gif" />
          </CancelButton>
          <UpdateButton>
            <Image Url="~/images/save.png" />
          </UpdateButton>
          <HeaderStyle HorizontalAlign="Center" />
          <CellStyle Cursor="pointer">
          </CellStyle>
        </dxwgv:GridViewCommandColumn>
        <dxwgv:GridViewDataTextColumn VisibleIndex="1" Width="60px">
          <EditFormSettings Visible="False" />
          <DataItemTemplate>
            <span style="cursor: pointer;" onclick="viewPhoto('<%#Eval("Id") %>')">
              <asp:Label ID="Label1" runat="server" CssClass="LinkItem" Text="<%$Resources:Strings, ViewPhoto %>"></asp:Label>
            </span>
          </DataItemTemplate>
        </dxwgv:GridViewDataTextColumn>
        <dxwgv:GridViewDataTextColumn Name="Locale" VisibleIndex="2" Width="60px">
          <EditFormSettings Visible="False" />
          <DataItemTemplate>
            <span style="cursor: pointer;" onclick="updateLocale('<%#Eval("Id") %>')">
              <asp:Label ID="Label1" runat="server" CssClass="LinkItem" Text="<%$Resources:Strings, UpdateLocale %>"></asp:Label>
            </span>
          </DataItemTemplate>
        </dxwgv:GridViewDataTextColumn>
        <dxwgv:GridViewDataTextColumn VisibleIndex="3" Caption="<%$ Resources:Strings, Name %>"
          FieldName="Name">
          <EditFormSettings Visible="True" VisibleIndex="0" />
          <HeaderStyle HorizontalAlign="Center" />
        </dxwgv:GridViewDataTextColumn>
        <dxwgv:GridViewDataComboBoxColumn Caption="<%$ Resources:Strings, Status %>" FieldName="Status"
          VisibleIndex="4">
          <PropertiesComboBox DataSourceID="xdsStatus" DisplayFormatString="{0}" TextField="Value"
            ValueField="Id" ValueType="System.String">
          </PropertiesComboBox>
          <EditFormSettings VisibleIndex="1" />
          <HeaderStyle HorizontalAlign="Center" />
        </dxwgv:GridViewDataComboBoxColumn>
        <dxwgv:GridViewDataTextColumn VisibleIndex="5" Caption="<%$Resources:Strings, ShowOnHome %>"
          FieldName="ShowOnHome" Width="20px">
          <EditFormSettings Visible="False" />
          <DataItemTemplate>
            <input id="radiobtn" runat="server" type="radio" style="cursor: pointer" checked='<%# Eval("ShowOnHome")!= null ?( Eval("ShowOnHome").ToString().Trim()=="True"?true:false): false %>' />
          </DataItemTemplate>
          <CellStyle HorizontalAlign="Center">
          </CellStyle>
        </dxwgv:GridViewDataTextColumn>
      </Columns>
      <StylesEditors>
        <ProgressBar Height="29px">
        </ProgressBar>
      </StylesEditors>
      <ImagesEditors>
        <CalendarPrevYear Height="19px" Width="23px" />
        <CalendarPrevMonth Height="19px" Width="19px" />
        <CalendarNextMonth Height="19px" Width="19px" />
        <CalendarNextYear Height="19px" Width="23px" />
      </ImagesEditors>
      <SettingsText ConfirmDelete="<%$Resources:Messages,ERR0006 %>" />
      <ClientSideEvents EndCallback="function(s, e){ongvList_EndCallback(s,e);}" />
    </dxwgv:ASPxGridView>
  </div>
  <asp:XmlDataSource ID="xdsStatus" runat="server" DataFile="~/App_Data/Status.xml"
    XPath="Items/VisibleStatus/Status"></asp:XmlDataSource>
  <asp:XmlDataSource ID="xdsLanguage" runat="server" DataFile="~/App_Data/Status.xml"
    XPath="Items/LanguageDisplay/Status"></asp:XmlDataSource>
  <div>
    <dxpc:ASPxPopupControl ID="pcAlbumLocale" runat="server" ClientInstanceName="pcAlbumLocale"
      HeaderText="<%$ Resources:Strings, Album %>" PopupHorizontalAlign="WindowCenter"
      PopupVerticalAlign="WindowCenter" AllowDragging="True" CloseAction="CloseButton"
      Height="150px" Modal="True" Width="350px">
      <CloseButtonImage Height="17px" Width="17px" />
      <SizeGripImage Height="12px" Width="12px" />
      <ContentCollection>
        <dxpc:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
          <div>
            <table width="100%">
              <tr>
                <td>
                  <dxe:ASPxLabel ID="lblErrorMsg" runat="server" ClientInstanceName="lblErrorMsg">
                  </dxe:ASPxLabel>
                  <asp:HiddenField ID="hfAlbumId" runat="server" />
                </td>
              </tr>
              <tr>
                <td>
                  <table width="100%">
                    <tr>
                      <td width="80px">
                        <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:Strings, Language %>"></asp:Literal>
                        :
                      </td>
                      <td>
                        <dxe:ASPxComboBox ID="cbxLanguage" SelectedIndex="0" runat="server" DataSourceID="xdsLanguage"
                          TextField="Value" ValueField="Id" ValueType="System.Int32" ClientInstanceName="cbxLanguage"
                          Width="200px">
                          <ButtonStyle Width="13px">
                          </ButtonStyle>
                          <ValidationSettings>
                            <ErrorImage Height="14px" Width="14px" />
                          </ValidationSettings>
                          <ClientSideEvents SelectedIndexChanged="function(s,e){oncbxLanguage_SelectedIndexChanged(s,e)}">
                          </ClientSideEvents>
                        </dxe:ASPxComboBox>
                      </td>
                    </tr>
                    <tr>
                      <td width="80px">
                        <asp:Literal ID="Literal3" runat="server" Text="<%$ Resources:Strings, Name %>"></asp:Literal>
                        :
                      </td>
                      <td>
                        <dxe:ASPxTextBox ID="txtName" runat="server" ClientInstanceName="txtName" Width="200px">
                          <ValidationSettings>
                            <ErrorImage Height="14px" />
                          </ValidationSettings>
                        </dxe:ASPxTextBox>
                      </td>
                    </tr>
                    <tr>
                      <td>
                        <asp:Literal ID="Literal13" runat="server" Text="<%$ Resources:Strings, Note %>"></asp:Literal>
                        :
                      </td>
                      <td>
                        <dxe:ASPxMemo ID="mmNote" ClientInstanceName="mmNote" runat="server" Height="71px"
                          Width="200px">
                        </dxe:ASPxMemo>
                      </td>
                    </tr>
                    <tr>
                      <td>
                      </td>
                      <td style="padding-top: 5px">
                        <div style="float: left;">
                          <dxe:ASPxButton ID="btnSaveLocale" runat="server" Text="<%$ Resources:Strings, Save %>">
                            <ClientSideEvents Click="function(s, e) {
                                    saveLocale();
	                                  e.processOnServer = false;  }" />
                          </dxe:ASPxButton>
                        </div>
                        <div style="float: left; padding-left: 3px;">
                          <dxe:ASPxButton ID="btnCancel" runat="server" Text="<%$ Resources:Strings, Cancel %>">
                            <ClientSideEvents Click="function(s, e) {
                                    pcAlbumLocale.Hide();
                                    e.processOnServer = false;  }" />
                          </dxe:ASPxButton>
                        </div>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </div>
        </dxpc:PopupControlContentControl>
      </ContentCollection>
    </dxpc:ASPxPopupControl>
    <dxcb:ASPxCallback ID="cbxCallback" ClientInstanceName="cbxCallback" runat="server"
      OnCallback="cbxCallback_Callback">
      <ClientSideEvents CallbackComplete="function(s,e){cbxCallback_CallbackComplete(s,e);}" />
    </dxcb:ASPxCallback>
  </div>

  <script type="text/javascript" language="javascript">
    function saveLocale() {
      pcWaiting.Show();
      cbxCallback.SendCallback('Save');
    }
    function viewPhoto(id) {
      window.location.href = 'PhotoList.aspx?albumId=' + id;
    }
    function updateLocale(id) {
      document.getElementById('<%=hfAlbumId.ClientID %>').value = id;
      setTimeout("cbxCallback.SendCallback('Load')", 10);
    }
    function setShowOnHome(id, show) {
      gvList.PerformCallback('ShowOnHome|' + id + '|' + show);
    }
    function ongvList_EndCallback(s, e) {
      var error = gvList.cpInnerError;
      if (error != '') {
        alertMessage(error);
      }
    }
    function oncbxLanguage_SelectedIndexChanged(s, e) {
      pcWaiting.Show();
      setTimeout("cbxCallback.SendCallback('Load')", 10);
    }

    function cbxCallback_CallbackComplete(s, e) {
      var para = e.parameter;
      pcWaiting.Hide();
      var results = e.result.split('|');
      if (para == 'Load') {
        if (results[0] == 'S') {
          txtName.SetText(results[1]);
          mmNote.SetText(results[2]);
          pcAlbumLocale.Show();
        }
      }
      else if (para == 'Save') {
        if (e.result == '') {
          alertMessage('<%=(string)GetGlobalResourceObject("Messages", "ERR0005") %>');
        }
        else {
          alertMessage(e.result);
        }
      }
    }
  </script>

</asp:Content>
